package capaPersistencia;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

import data.ProductoVO;

public class cargaDatos {


public static void main(String[] args) throws IOException {
		FileInputStream fstream = new FileInputStream("Datos1.0.txt");
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String linea;
		while ((linea = br.readLine()) != null) {
		
//		linea = br.readLine();

			/*
			 * Dividir esa linea
			 */
			System.out.println("insertando producto");
			String[] atrib = linea.split("-");
			ProductoVO producto;
			ModuloProductos modProds = new ModuloProductos();
			
			for(String str : atrib) System.out.println(str);

			if (atrib[1].equals("Ropa")) {
				System.out.println("aqui");
				producto = new ProductoVO(atrib[0], atrib[2], atrib[1],
						Double.parseDouble(atrib[3]), Integer.parseInt(atrib[4]), atrib[5], atrib[6], atrib[7],
						atrib[8]);
				
				modProds.insertarProductoRopa(producto);

			}

			if (atrib[1].equals("Libro") || atrib[1].equals("Pelicula")) {
				producto = new ProductoVO(atrib[0], atrib[2], atrib[1],
						Double.parseDouble(atrib[3]), Integer.parseInt(atrib[4]), atrib[5], atrib[6], atrib[7],
						Integer.parseInt(atrib[8]), atrib[9]);
				modProds.insertarProductoLibroPeli(producto);
			}

			if (atrib[1].equals("Coleccionable")) {
				producto = new ProductoVO(atrib[0], atrib[1], atrib[1],
						Double.parseDouble(atrib[3]), Integer.parseInt(atrib[4]), atrib[5], atrib[6], atrib[7]);
				modProds.insertarProductoColeccionables(producto);
			}
		}

		in.close();
	
	}
}